<?php
declare ( strict_types = 1 )
	;

namespace App\Controllers\Test;

use Swoft\Http\Server\Annotation\Mapping\Controller;
use Swoft\Rpc\Client\Annotation\Mapping\Reference;
use Lib\Test\IUpdateMoney;
use Lib\Test\IUpdateGoods;
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
use Swoft\Http\Server\Annotation\Mapping\RequestMethod;
use Initiating\Annotation\Mapping\GloablTransaction;

/**
 * @Controller(prefix="/test")
 * 
 * @author mg
 *        
 */
class TestController {
	/**
	 * @Reference(pool="user.pool")
	 * 
	 * @var IUpdateMoney
	 */
	private $balanceService;
	
	/**
	 * @Reference(pool="user.pool")
	 * 
	 * @var IUpdateGoods
	 */
	private $goodsService;
	
	/**
	 * @RequestMapping(route="index", method=RequestMethod::POST)
	 * @GloablTransaction(timeout=3)
	 * @return bool
	 */
	public function index(): bool {
		vdump ( 111111 );
		$status = $this->balanceService->parse ( 100 );
		vdump ( $status );
		if (! $status) {
			
			return false;
		}
		
		$status = $this->goodsService->parse ( 600 );
		vdump ( $status );
		
		if (! $status) {
			
			return false;
		}
		
		vdump ( '-----------------------' );
		return true;
	}
}